import React from 'react';
import { Button } from 'antd';
import { connect } from 'umi';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import HistoryTabCard from '@/components/HistoryTabCard';
import { StartTaskModal } from '../../components';
import Audited from './components/Audited';
import PendingAudit from './components/PendingAudit';
import styles from './index.less';
/**
 *  我执行的 功能菜单
 */
const MyAudit = ({ global }) => {
    // console.log('PendingAcceptance -> global', global);
    const { taskCount } = global;
    const { toAuditTaskNum } = taskCount;
    // 发起任务弹窗显示与否
    const [startModalVisible, setStartModalVisible] = React.useState(false);

    const tabList = [
        {
            key: 'tab1',
            tab: `待审核(${toAuditTaskNum})`
        },
        {
            key: 'tab2',
            tab: '已审核'
        }
    ];
    const extraButtons = (
        <Button
            type="primary"
            className={styles.auditButton}
            onClick={() => {
                setStartModalVisible(true);
            }}
        >
            发起任务
        </Button>
    );

    return (
        <PageHeaderWrapper>
            <HistoryTabCard bordered={false} tabList={tabList} tabBarExtraContent={extraButtons}>
                <PendingAudit />
                <Audited />
            </HistoryTabCard>
            <StartTaskModal visible={startModalVisible} setVisible={setStartModalVisible} />
        </PageHeaderWrapper>
    );
};

export default connect(({ global }) => ({
    global
}))(MyAudit);
